<template>
  <div class="echartsBox">
    <div id="eqActivationGauge" class="allWidthHeight" />
    <span>实时开动率</span>
  </div>
</template>
<script>
import * as echarts from 'echarts'
export default {
  props: {},
  data() {
    return {
      myChart: null
    }
  },
  watch: {},
  mounted() {},
  methods: {
    infoSize() {
      this.myChart.resize()
    },
    /* 实时开动率echarts */
    setEqActivationGaugeGauge(data) {
      const option = {
        series: [
          {
            type: 'gauge',
            radius: '100%',
            center: ['50%', '50%'],
            axisLine: {
              lineStyle: {
                width: 10,
                color: [
                  [0.8, '#42E4FB'],
                  [1, '#FAC53B']
                ]
              }
            },
            pointer: {
              length: '80%',
              width: 2,
              itemStyle: {
                color: 'auto'
              }
            },
            axisTick: {
              distance: 0,
              length: 3,
              lineStyle: {
                color: '#42E4FB',
                width: 1
              }
            },
            splitLine: {
              distance: 0,
              length: 5,
              lineStyle: {
                color: '#42E4FB',
                width: 1
              }
            },
            axisLabel: {
              color: '#42E4FB',
              distance: 10,
              fontSize: 8
            },
            detail: {
              valueAnimation: true,
              formatter: '{value}%',
              color: '#fff',
              fontSize: 10,
              offsetCenter: [0, '40%']
            },
            data: [
              {
                value: data.beginRate
              }
            ]
          }
        ]
      }
      if (
        this.myChart != null &&
        this.myChart !== '' &&
        this.myChart !== undefined
      ) {
        this.myChart.dispose() // 销毁
      }
      this.myChart = echarts.init(document.getElementById('eqActivationGauge'))
      this.myChart.clear()
      this.myChart.setOption(option, true)
    }
  }
}
</script>
<style lang='scss' scoped>
.echartsBox {
  width: 100%;
  // padding: 0 20px;
  height: 50%;
  position: relative;
  span {
    position: absolute;
    bottom: 5px;
    color: #fff;
    width: 100%;
    text-align: center;
    font-size: 14px;
    color: #19c9e7;
  }
}
</style>
